package com.mtask.common.dto.vo;


import com.mtask.common.entity.web.SystemConfig;
import lombok.Builder;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

@Builder
@Data
public class SystemConfVo {
    private String key;
    private String value;
    private LocalDateTime createAt;

    public static SystemConfVo fromEntity(SystemConfig config) {
        return SystemConfVo.builder().key(config.getKey()).value(config.getValue()).createAt(config.getCreateAt()).build();
    }

    public static SystemConfig toEntity(SystemConfVo confVo) {
        return SystemConfig.builder().key(confVo.getKey()).value(confVo.getValue()).build();
    }

    public static List<SystemConfVo> fromEntities(List<SystemConfig> configs) {
        return configs.stream().map(SystemConfVo::fromEntity).collect(Collectors.toList());
    }

    public static List<SystemConfig> toEntities(List<SystemConfVo> confVos) {
        return confVos.stream().map(SystemConfVo::toEntity).collect(Collectors.toList());
    }
}
